<?php

namespace App\Http\Controllers\Home;

use App\Model\Category;
use App\Model\FollowUser;
use App\Models\Archive\Archive;
use App\Models\Archive\ArchiveVisit;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Input;


class qygController extends Controller
{
    public function index($category)
    {

        $cate = $this->aboutCate();
        foreach ($cate as $v){
            if($v->cate_url == $category){
                $cate_info = Category::where('cate_name',$v->cate_name)->first();
            }
        }
        //栏目内容
        $archive = Archive::where('category_id',$cate_info->cate_id)->get();
        $archive = isset($archive)?$archive:"";
        return view('home.qyg'.'.'.$cate_info->cate_templates)
            ->with('info',$cate_info)
            ->with('cate',$cate)
            ->with('category',$category)
            ->with('archive',$archive)
            ;
    }

    public function aboutCate()
    {
        $about = Category::where('cate_name','奇异果资讯')->first();
        $children = Category::where('cate_pid',$about->cate_id)->orderBy('cate_weight','asc')->get();
        return $children;
    }

}
